package com.gr3g.dev.learndraw;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

/**
 * @author Gregory Tardivel
 *
 */
public abstract class AbstractScrollActivity extends AbstractActivity {

	private TableLayout tableau;
	private TableLayout.LayoutParams params;
	
	private TableRow row;
	
	protected abstract int getViewTitle();
	
	@Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.setContentView(R.layout.levels);
     
        tableau = (TableLayout) this.findViewById(R.id.menu);
        
        params = new TableLayout.LayoutParams();
        params.topMargin = 5;
        params.leftMargin = 5;
        params.rightMargin = 5;
        params.bottomMargin = 5;
        params.weight = 1;
        params.gravity = Gravity.CENTER_HORIZONTAL;
        params.width = TableLayout.LayoutParams.MATCH_PARENT;

        this.findViewById(R.id.imgRetour).setOnClickListener(this.home);

        row = (TableRow) this.findViewById(R.id.tableRow2);
        row.setLayoutParams(params);
        
        final TextView titre = (TextView) this.findViewById(R.id.txtTitre);
        titre.setText(getViewTitle());
    }
	
	protected void addViewToRow(View view) {
		row.addView(view);
	}
	
	protected void addRow() {
		row = new TableRow(this);
		row.setLayoutParams(params);
		tableau.addView(row);
	}
}
